
package vv.lines.view.swing;

import vv.lines.core.IActionHandler;
import vv.lines.view.FieldView;
import vv.lines.view.View;

import javax.swing.*;
import java.awt.*;

/**
 *
 * @author vpotapenko
 */
public class SwingFieldView extends JPanel implements FieldView {

    private SwingFieldComponent fieldComponent;

    public SwingFieldView() {
        setLayout(new BorderLayout());
        
        initGameFieldView();
    }

    public void add(View view) {
        fieldComponent.add(view);
    }

    public void remove(View view) {
        fieldComponent.remove(view);
    }

    public void updateItemsZOrder() {
        fieldComponent.updateItemsZOrder();
    }

    public int getFieldHeight() {
        return fieldComponent.getHeight();
    }

    public int getFieldWidth() {
        return fieldComponent.getWidth();
    }

    private void initGameFieldView() {
        fieldComponent = new SwingFieldComponent();
        add(fieldComponent, BorderLayout.CENTER);
    }

    public void setHandler(IActionHandler actionHandler) {
        fieldComponent.setHandler(actionHandler);
    }
}
